package exam;

import java.util.Scanner;

public class Wangyi_1 {
    static int n,k;
    static int[] numbers1;
    static int[] numbers2;
    static int max = 0;
    static int sum = 0;
    static int sum2 = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        numbers1 = new int[n];
        numbers2 = new int[n];
        for (int i=0;i<n;i++){
            numbers1[i] = sc.nextInt();
        }
        for (int i=0;i<n;i++){
            numbers2[i] = sc.nextInt();
        }
        f();
    }

    public static void f(){
        for(int i=0;i<n;i++){
            if(numbers2[i]==1){
                sum = sum + numbers1[i];
            }
        }

        for(int i=0;i<n-k;i++){
            for(int j=i;j<i+k;j++){
                if(numbers2[j] == 0){
                    sum2 = sum2 + numbers1[j];
                }
            }
            if(sum2 > max){
                max = sum2;
            }
            sum2 = 0;
        }
        System.out.println(sum+max);
    }
}
